BaseProtocolServer

StockSharp.Server.Core

プロトコルサーバー(FIX、SBEなど)のベースクラス。共有インフラ:ライフサイクル、セッション、サブスクリプション、メッセージチャネル、背景タスクが含まれています。

継承元: BaseLogReceiver

実装: IHostedProtocolServer, IProtocolServer, ILogReceiver, ILogSource, IDisposable, IMessageListener

コンストラクター

BaseProtocolServer
protected BaseProtocolServer(TSettings settings, IAuthorization authorization)
baseProtocolServer = BaseProtocolServer(settings, authorization)

Initializes a new instance.

settings
Server settings.
authorization
The customer authentication.

プロパティ

Address
public abstract EndPoint Address { get; set; }
value = baseProtocolServer.Address
baseProtocolServer.Address = value

Where the server listens.

Authorization
public IAuthorization Authorization { get; }
value = baseProtocolServer.Authorization

The customer authentication.

LoginRateLimiter
protected LoginRateLimiter LoginRateLimiter { get; private set; }
value = baseProtocolServer.LoginRateLimiter
baseProtocolServer.LoginRateLimiter = value

ログインの試みのためのレートリミッター(すべてのリスナー間で共有)。

Sessions
public IEnumerable<IMessageListenerSession> Sessions { get; }
value = baseProtocolServer.Sessions

アクティブセッション。

Settings
public TSettings Settings { get; }
value = baseProtocolServer.Settings

設定。

State
public ChannelStates State { get; protected set; }
value = baseProtocolServer.State
baseProtocolServer.State = value

ステートストレージの根本的な状態を取得します。

メソッド

AcceptClientsAsync
protected Task AcceptClientsAsync(TcpListener listener, Func<TcpClient, CancellationToken, Task> handleClient, CancellationToken cancellationToken)
result = baseProtocolServer.AcceptClientsAsync(listener, handleClient, cancellationToken)

Accept clients on a listener for as long as the server runs.

listener
The listener to accept on.
handleClient
What the protocol does with an accepted client. It is not awaited, so one client's session does not hold up the next accept.
cancellationToken
Cancellation token.
AddSubscription
public void AddSubscription(ServerSubscription subscription)
baseProtocolServer.AddSubscription(subscription)

サブスクリプションを追加。

subscription
サブスクリプション。
AlwaysWrites
private static Func<TSubscription, TClientSession, string, CancellationToken, ValueTask<bool>> AlwaysWrites(Func<TSubscription, TClientSession, string, CancellationToken, ValueTask> handler)
result = BaseProtocolServer.AlwaysWrites(handler)

Wrap a handler that always writes so it reports the write the way the session's pump expects.

ClearState
protected virtual void ClearState()
baseProtocolServer.ClearState()

すべての状態をクリア:リスナー、セッション、サブスクリプション。

ClientOrderIdsOf
protected ClientOrderIdRegistry ClientOrderIdsOf(TClientSession session, string clientCode)
result = baseProtocolServer.ClientOrderIdsOf(session, clientCode)

The ClOrdIds a client's live orders hold, whichever of its connections placed them.

session
A session of the client.
clientCode
The client an order command of a service login names; ignored for any other login.

戻り値: The client's registry.

Convert
protected string Convert(string value)
result = baseProtocolServer.Convert(value)

設定されている場合は、テキストをラテンに変換します。

CreateOrderFailure
protected static ExecutionMessage CreateOrderFailure(OrderRegisterMessage command, Exception error)
result = BaseProtocolServer.CreateOrderFailure(command, error)

The report an order command refused before it reached the venue is answered with. It repeats what the command asked for, because the client has nothing else to match the failure against: the order never got an id on the venue.

command
The refused order command.
error
Why it was refused.

戻り値: The execution report to send back.

CreateOrderSubscription
protected abstract TSubscription CreateOrderSubscription(TClientSession session, string clOrdId, long transactionId)
result = baseProtocolServer.CreateOrderSubscription(session, clOrdId, transactionId)

The subscription an order's reports reach its client by.

session
The connection the reports go to.
clOrdId
The ClOrdId the client gave the order.
transactionId
The number the order goes by.

戻り値: The subscription.

CreateSubscription
protected abstract TSubscription CreateSubscription(TClientSession session, string requestId, ServerSubscription subscription, MessageTypes type)
result = baseProtocolServer.CreateSubscription(session, requestId, subscription, type)

サブスクリプション情報インスタンスを作成します。

Disconnect
public void Disconnect(IMessageListenerSession session)
baseProtocolServer.Disconnect(session)

セッションの切断

session
セッション
DisposeManaged
protected override void DisposeManaged()
baseProtocolServer.DisposeManaged()

リソースのリリース

EnqueueMessage
protected void EnqueueMessage(TSubscription[] subscribers, Func<TSubscription, TClientSession, string, CancellationToken, ValueTask> handler, CancellationToken cancellationToken)
baseProtocolServer.EnqueueMessage(subscribers, handler, cancellationToken)

複数の加入者のためのメッセージ

subscribers
Subscribers to write to.
handler
Writes the message for one subscriber. It always writes.
cancellationToken
Cancellation token.
EnqueueMessage
protected void EnqueueMessage(TSubscription[] subscribers, Func<TSubscription, TClientSession, string, CancellationToken, ValueTask<bool>> handler, CancellationToken cancellationToken)
baseProtocolServer.EnqueueMessage(subscribers, handler, cancellationToken)

複数の加入者(ボール結果付き)のメッセージ

subscribers
Subscribers to write to.
handler
Writes the message for one subscriber and answers when it wrote nothing.
cancellationToken
Cancellation token.
EnqueueMessage
protected void EnqueueMessage(TSubscription subscription, Func<TSubscription, TClientSession, string, CancellationToken, ValueTask> handler, CancellationToken cancellationToken)
baseProtocolServer.EnqueueMessage(subscription, handler, cancellationToken)

単一のサブスクリプションのメッセージの入力

subscription
The subscription the write belongs to. Its session and request id address the write.
handler
Writes the message. It always writes.
cancellationToken
Cancellation token.
EnqueueMessage
protected void EnqueueMessage(TSubscription subscription, Func<TSubscription, TClientSession, string, CancellationToken, ValueTask<bool>> handler, CancellationToken cancellationToken)
baseProtocolServer.EnqueueMessage(subscription, handler, cancellationToken)

単一のサブスクリプション( bool result と)のメッセージのキューイング。

subscription
The subscription the write belongs to. Its session and request id address the write.
handler
Writes the message and answers when it wrote nothing.
cancellationToken
Cancellation token.
EnqueueMessage
protected void EnqueueMessage(TClientSession session, Func<TClientSession, CancellationToken, ValueTask> handler, CancellationToken cancellationToken)
baseProtocolServer.EnqueueMessage(session, handler, cancellationToken)

Enqueue a write addressed to a session rather than to a subscription: session-level traffic answers no request, so the handler takes neither a subscription nor a request id.

session
Session to write to.
handler
Writes the message. It always writes.
cancellationToken
Cancellation token.
EnqueueMessage
private void EnqueueMessage(TSubscription subscription, TClientSession session, string requestId, Func<TSubscription, TClientSession, string, CancellationToken, ValueTask<bool>> handler, CancellationToken cancellationToken)
baseProtocolServer.EnqueueMessage(subscription, session, requestId, handler, cancellationToken)

コア・エンキュー: クライアント・セッションでスケジュール作業を行います。

GetRawId
protected static string GetRawId(long id)
result = BaseProtocolServer.GetRawId(id)

The transaction id as text, for an answer the client named no id of its own for.

id
The transaction id.

戻り値: The id as text, or an empty string when there is no id.

GetSessionKey
protected abstract string GetSessionKey(TClientSession session)
result = baseProtocolServer.GetSessionKey(session)

クライアントセッション(e.g@.SenderCompId)に利用されるキーを取得します。

GetSubscriptions
public IEnumerable<ServerSubscription> GetSubscriptions(IMessageListenerSession session)
result = baseProtocolServer.GetSubscriptions(session)

指定したセッションのサブスクリプションを取得します。

session
セッション

戻り値: サブスクリプション。

HandLiveOrderToLiveConnection
protected void HandLiveOrderToLiveConnection(TClientSession addressee, Message message)
baseProtocolServer.HandLiveOrderToLiveConnection(addressee, message)

Hands a report of a live order to a connection of the client that placed it, when the connection that placed it has gone.

addressee
The connection the module addressed the report to, or .
message
What the module sent.
HasSubscriptions
public bool HasSubscriptions(DataType dataType, SecurityId securityId)
result = baseProtocolServer.HasSubscriptions(dataType, securityId)

加入者があります。

IsAnotherSessionsSubscription
protected bool IsAnotherSessionsSubscription(TClientSession session, long transactionId)
result = baseProtocolServer.IsAnotherSessionsSubscription(session, transactionId)

Whether the subscription a session named is one only another session holds.

session
The session asking.
transactionId
The subscription it named.

戻り値: when the subscription belongs to somebody else.

IsOrphanStatusRow
protected bool IsOrphanStatusRow(ExecutionMessage execMsg)
result = baseProtocolServer.IsOrphanStatusRow(execMsg)

Whether an order row names no portfolio, so no status subscription is handed it: client connectors refuse an order with an empty portfolio. The answer to a command goes out regardless.

execMsg
The execution report.

戻り値: when status subscriptions are not handed the row.

IsStubSubscription
protected abstract bool IsStubSubscription(TSubscription subscription)
result = baseProtocolServer.IsStubSubscription(subscription)

サブスクリプションがスタブ(プレースホルダー)であるかどうかを確認してください。

LoadAsync
public override Task LoadAsync(SettingsStorage storage, CancellationToken cancellationToken)
result = baseProtocolServer.LoadAsync(storage, cancellationToken)

Load settings.

storage
Settings storage.
cancellationToken
CancellationToken

戻り値: Task

OnClearListenerState
protected abstract void OnClearListenerState()
baseProtocolServer.OnClearListenerState()

明確なプロトコル固有のリスナー状態(停止リスナーなど)。

OnStartListeners
protected abstract void OnStartListeners(CancellationToken cancellationToken)
baseProtocolServer.OnStartListeners(cancellationToken)

プロトコル固有のリスナー(TCPなど)を開始します。_backgroundTasksにタスクを追加します。

ProcessInMessage
protected abstract void ProcessInMessage(IMessageListenerSession addressee, Message message, CancellationToken cancellationToken)
baseProtocolServer.ProcessInMessage(addressee, message, cancellationToken)

Process an incoming message and route to subscribed clients.

addressee
The only session the message is for, or when it is for every subscriber to it.
ProcessLogout
protected virtual void ProcessLogout(TClientSession session)
baseProtocolServer.ProcessLogout(session)

クライアントのログアウト/切断を処理する。

RaiseNewOutMessage
protected void RaiseNewOutMessage(IMessageListenerSession session, Message message)
baseProtocolServer.RaiseNewOutMessage(session, message)

チャンネルにメッセージを発信する。

RaiseSessionConnected
protected void RaiseSessionConnected(IMessageListenerSession session)
baseProtocolServer.RaiseSessionConnected(session)

レイズセッション接続イベント。

RaiseSessionDisconnected
protected void RaiseSessionDisconnected(IMessageListenerSession session)
baseProtocolServer.RaiseSessionDisconnected(session)

セッションの切断イベントを上げます。

ReleaseClOrdIdOfEndedOrder
protected void ReleaseClOrdIdOfEndedOrder(TSubscription[] subscriptions, ExecutionMessage execMsg)
baseProtocolServer.ReleaseClOrdIdOfEndedOrder(subscriptions, execMsg)

Gives a client order id back once the order holding it has ended, so the client may number its next order the same way.

subscriptions
The subscriptions the report is going to.
execMsg
The execution report.
ReleaseOrderTransactionId
protected void ReleaseOrderTransactionId(TClientSession session, string clientCode, long transactionId)
baseProtocolServer.ReleaseOrderTransactionId(session, clientCode, transactionId)

Gives back the number an order holds, once the order has ended or its command did not go on after all.

session
A session of the client.
clientCode
The client an order of a service login belongs to; ignored for any other login.
transactionId
The transaction the order travels under.
RemoveSubscription
public bool RemoveSubscription(ServerSubscription subscription)
result = baseProtocolServer.RemoveSubscription(subscription)

サブスクリプションを削除します。

subscription
サブスクリプション。

戻り値: サブスクリプションが見つからなかった場合、そうでなければ。

RequestIdOf
protected static string RequestIdOf(long transactionId)
result = BaseProtocolServer.RequestIdOf(transactionId)

The id a transaction goes out under, or for none.

transactionId
The transaction id.

戻り値: The id as text, or when there is no id.

Resume
public bool Resume(ServerSubscription subscription)
result = baseProtocolServer.Resume(subscription)

サブスクリプションを再開します。

subscription
サブスクリプション。

戻り値: サブスクリプションが見つからなかった場合、そうでなければ。

Resume
public void Resume(IMessageListenerSession session)
baseProtocolServer.Resume(session)

セッションを再開します。

session
セッション
RunAsync
public IAsyncEnumerable<ValueTuple<IMessageListenerSession, Message>> RunAsync(CancellationToken cancellationToken)
result = baseProtocolServer.RunAsync(cancellationToken)

サーバをオープンし、最後に閉じる。

SaveAsync
public override Task SaveAsync(SettingsStorage storage, CancellationToken cancellationToken)
result = baseProtocolServer.SaveAsync(storage, cancellationToken)

Save settings.

storage
Settings storage.
cancellationToken
CancellationToken

戻り値: Task

ScheduleSessionWork
protected abstract void ScheduleSessionWork(TClientSession session, ServerSubscription subscription, string requestId, Func<TClientSession, string, CancellationToken, ValueTask<bool>> handler)
baseProtocolServer.ScheduleSessionWork(session, subscription, requestId, handler)

クライアントセッションのアウトゴイングキューでタスクをスケジュールします。

SendInMessage
public virtual bool SendInMessage(IMessageListenerSession session, Message message)
result = baseProtocolServer.SendInMessage(session, message)

Send a message to one named session.

session
The session the message is for.
message
The message.

戻り値: when it was taken for sending.

SendInMessage
public virtual bool SendInMessage(Message message)
result = baseProtocolServer.SendInMessage(message)

クライアントに処理およびルーティングを行うためのサーバーに、インカムメッセージを送信する。

StartServer
protected void StartServer(CancellationToken cancellationToken)
baseProtocolServer.StartServer(cancellationToken)

サーバを起動: ステートを初期化し、リスナーとバックグラウンドタスクを開始します。

StateConditionalOrderType
protected static void StateConditionalOrderType(OrderReplaceMessage replace)
BaseProtocolServer.StateConditionalOrderType(replace)

Takes a replace carrying a condition for the replace of a conditional order, as a registration carrying one places one: a replace may leave its type unsaid.

replace
The replace as it was read.
StopServer
protected void StopServer()
baseProtocolServer.StopServer()

サーバを停止:タスクをキャンセル、チャンネルをクリア、状態をクリアします。

Suspend
public bool Suspend(ServerSubscription subscription)
result = baseProtocolServer.Suspend(subscription)

サブスクリプションを中断します。

subscription
サブスクリプション。

戻り値: サブスクリプションが見つからなかった場合、そうでなければ。

Suspend
public void Suspend(IMessageListenerSession session)
baseProtocolServer.Suspend(session)

セッションを中断します。

session
セッション
ToTransactionId
protected static long ToTransactionId(string requestId)
result = BaseProtocolServer.ToTransactionId(requestId)

The transaction id a request runs under: the number its client gave it.

requestId
The id the client gave the request.

戻り値: The transaction id.

TryAuthorizeAsync
protected Task<ValueTuple<string, long>> TryAuthorizeAsync(string login, string password, EndPoint remoteEndPoint, CancellationToken cancellationToken)
result = baseProtocolServer.TryAuthorizeAsync(login, password, remoteEndPoint, cancellationToken)

Check a client's credentials, honouring the login rate limiter.

login
The login the client offered.
password
The password the client offered.
remoteEndPoint
Where the client connected from.
cancellationToken
CancellationToken

戻り値: The session token and the broker user behind the login, or when the client is refused. A refusal carries no reason: rate limited, unknown login and wrong password are one answer, so nothing here tells a caller which half of the credentials it got right.

TryClaimOrderTransactionId
protected bool TryClaimOrderTransactionId(TClientSession session, string clientCode, string clOrdId, long? orderId, long transactionId, Exception refusal)
result = baseProtocolServer.TryClaimOrderTransactionId(session, clientCode, clOrdId, orderId, transactionId, refusal)

Claims the ClOrdId an order command opens under, which is also the transaction id it runs on.

session
Client session.
clientCode
The client the order is for, which a service login names.
clOrdId
The id the client gave the order.
orderId
The id the order is written down under, or when the command names none.
transactionId
The transaction id the order runs on.
refusal
Why the order is refused, when it is.

戻り値: when the order may go on.

TryReadCancelTransactionId
protected bool TryReadCancelTransactionId(TClientSession session, string clientCode, string clOrdId, long transactionId, Exception refusal)
result = baseProtocolServer.TryReadCancelTransactionId(session, clientCode, clOrdId, transactionId, refusal)

The transaction id a command that opens no order runs on: a cancel, a mass cancel, or a replace that names its order by the order's id alone.

session
Client session.
clientCode
The client the command is for, which a service login names.
clOrdId
The id the client gave the command.
transactionId
The transaction id the command runs on.
refusal
Why the command is refused, when it is.

戻り値: when the command may go on.

TryReadOrderTransactionId
protected static bool TryReadOrderTransactionId(string clOrdId, long transactionId, Exception refusal)
result = BaseProtocolServer.TryReadOrderTransactionId(clOrdId, transactionId, refusal)

The transaction id of the order a ClOrdId names.

clOrdId
The ClOrdId.
transactionId
The transaction id.
refusal
Why the ClOrdId is refused, when it is not a positive whole number.

戻り値: when the ClOrdId is such a number.

TryReadOrigTransactionId
protected static bool TryReadOrigTransactionId(string origClOrdId, long transactionId, Exception refusal)
result = BaseProtocolServer.TryReadOrigTransactionId(origClOrdId, transactionId, refusal)

The client's number of the order a cancel or a replace names, or zero when it names the order by the order's id alone.

origClOrdId
The OrigClOrdId the command carries.
transactionId
The order's number, or zero.
refusal
Why the command is refused, when it is.

戻り値: when the command may go on.

TryTakeReplaceTransactionId
protected bool TryTakeReplaceTransactionId(TClientSession session, string clientCode, string clOrdId, long? orderId, bool isMove, long transactionId, Exception refusal)
result = baseProtocolServer.TryTakeReplaceTransactionId(session, clientCode, clOrdId, orderId, isMove, transactionId, refusal)

The transaction id a replace runs on.

session
Client session.
clientCode
The client the replace is for, which a service login names.
clOrdId
The id the client gave the replace.
orderId
The id the order is written down under, or when the replace names none.
isMove
Whether the replace names the client's previous number of the order.
transactionId
The transaction id the replace runs on.
refusal
Why the replace is refused, when it is.

戻り値: when the replace may go on.

TryToTransactionId
protected static bool TryToTransactionId(string requestId, long transactionId)
result = BaseProtocolServer.TryToTransactionId(requestId, transactionId)

The transaction id a request names, when the id its client gave is a positive whole number.

requestId
The id the client gave the request.
transactionId
The transaction id.

戻り値: when the id is such a number.

イベント

SessionConnected
public event Action<IMessageListenerSession> SessionConnected
baseProtocolServer.SessionConnected += handler

セッションコネクティッドイベント。

SessionDisconnected
public event Action<IMessageListenerSession> SessionDisconnected
baseProtocolServer.SessionDisconnected += handler

セッションの切断イベント。

StateChanged
public event Action StateChanged
baseProtocolServer.StateChanged += handler

状態変更イベント。

SubscriptionChanged
public event Action<ServerSubscription> SubscriptionChanged
baseProtocolServer.SubscriptionChanged += handler

クライアントサブスクリプションが変更されたイベント。

フィールド

_backgroundTasks
protected readonly List<Task> _backgroundTasks
value = baseProtocolServer._backgroundTasks

背景タスク(クライアント、プロセスメッセージなど)

_changedSubscriptions
protected readonly SynchronizedSet<ServerSubscription> _changedSubscriptions
value = baseProtocolServer._changedSubscriptions

サブスクリプションの終了通知を変更しました。

_clientSessions
protected readonly CachedSynchronizedDictionary<string, CachedSynchronizedList<TClientSession>> _clientSessions
value = baseProtocolServer._clientSessions

セッションキー(e.gSenderCompId@)をグループ化したクライアントセッション。

_incomingMessages
protected readonly Channel<ValueTuple<IMessageListenerSession, Message>> _incomingMessages
value = baseProtocolServer._incomingMessages

メッセージチャネルの受信。

_outgoingMessages
protected readonly Channel<ValueTuple<IMessageListenerSession, Message>> _outgoingMessages
value = baseProtocolServer._outgoingMessages

メッセージチャンネル(セッション+メッセージペア)を外します。

_subscriptions
protected readonly SessionSubscriptions<TSubscription, TClientSession> _subscriptions
value = baseProtocolServer._subscriptions

サブスクリプションホルダー。